package com.wanglibao.woodtrade.woodtrade;

import android.app.Activity;
import android.app.Application;
import android.app.NotificationManager;
import android.content.Context;

import com.facebook.drawee.backends.pipeline.Fresco;
import com.wanglibao.woodtrade.woodtrade.model.WoodType;
import com.wanglibao.woodtrade.woodtrade.model.WoodTypeDetail;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

/**
 * Created by lugg on 2016/4/5.
 */
public class MyApplication extends Application{

    private static Context context;

    public List<Activity> activityList = new LinkedList<Activity>();

    public List<WoodType> woodTypeList = new ArrayList<>();

    public List<WoodTypeDetail> woodTypeDetailList = new ArrayList<>();

    public List<String> woodTypeStringLists = new ArrayList<>();

    @Override
    public void onCreate() {
        super.onCreate();
        context = getApplicationContext();
        Fresco.initialize(context);
        testWoodType();
    }

    private void testWoodType() {
        WoodType woodType = new WoodType("1","红木");
        woodTypeList.add(woodType);
        woodType = new WoodType("2","杨木");
        woodTypeList.add(woodType);
        woodType = new WoodType("3","松木");
        woodTypeList.add(woodType);
        woodType = new WoodType("4","梨木");
        woodTypeList.add(woodType);

        for (WoodType woodType1:woodTypeList){
            woodTypeStringLists.add(woodType1.name);
        }

        WoodTypeDetail woodTypeDetail = new WoodTypeDetail("1","1","越南红木");
        woodTypeDetailList.add(woodTypeDetail);
        woodTypeDetail = new WoodTypeDetail("2","1","上好的檀木");
        woodTypeDetailList.add(woodTypeDetail);
        woodTypeDetail = new WoodTypeDetail("3","1","国产乌檀");
        woodTypeDetailList.add(woodTypeDetail);
        woodTypeDetail = new WoodTypeDetail("4","2","河南杨木");
        woodTypeDetailList.add(woodTypeDetail);
        woodTypeDetail = new WoodTypeDetail("5","2","小白杨");
        woodTypeDetailList.add(woodTypeDetail);
        woodTypeDetail = new WoodTypeDetail("6","2","美国红杨");
        woodTypeDetailList.add(woodTypeDetail);
        woodTypeDetail = new WoodTypeDetail("7","3","迎客松");
        woodTypeDetailList.add(woodTypeDetail);
        woodTypeDetail = new WoodTypeDetail("8","3","墓地松");
        woodTypeDetailList.add(woodTypeDetail);
        woodTypeDetail = new WoodTypeDetail("9","3","咬定青山不放松");
        woodTypeDetailList.add(woodTypeDetail);
        woodTypeDetail = new WoodTypeDetail("10","4","黄花梨");
        woodTypeDetailList.add(woodTypeDetail);
        woodTypeDetail = new WoodTypeDetail("11","4","大黄梨");
        woodTypeDetailList.add(woodTypeDetail);
        woodTypeDetail = new WoodTypeDetail("12","4","皇冠梨");
        woodTypeDetailList.add(woodTypeDetail);
    }


    public static Context getContext(){
        return context;
    }

    public void exit() {
        NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
        manager.cancelAll();
        for (Activity activity : activityList) {
            activity.finish();
        }
        System.exit(0);
    }

    public void addActivity(Activity activity){
        activityList.add(activity);
    }
}
